<?php

/**
 * Description of Dispatcher
 *
 * @author     Mon Zafra <monzee at gmail>
 * @copyright  (c)2009 Mon Zafra
 * @category   Mz
 * @package
 * @license    http://mz-project.googlecode.com/svn/trunk/LICENSE   MIT License
 * @version    SVN: $Id$
 */
class Mz_Controller_Dispatcher implements Zend_Controller_Dispatcher_Interface
{
    protected $_params = array();
    protected $_request;
    protected $_response;
    protected $_defaultAction = 'index';
    protected $_defaultController = 'index';
    protected $_defaultModule = 'default';
    protected $_controllerDirs = array();

    public function addControllerDirectory($path, $module = null)
    {
        $module = null === $module ? $this->_defaultModule : $module;
        $this->_controllerDirs[$module] = rtim($path, '/\\');
        return $this;
    }

    public function clearParams($name = null)
    {
        if (null === $name) {
            $this->_params = array();
        } else if (array_key_exists($name, $this->_params)) {
            unset($this->_params[$name]);
        }
        return $this;
    }

    public function dispatch(Zend_Controller_Request_Abstract $request, Zend_Controller_Response_Abstract $response)
    {
    }

    public function formatActionName($unformatted)
    {
        return $unformatted . 'Action';
    }

    public function formatControllerName($unformatted)
    {
        return ucfirst($unformatted) . 'Controller';
    }

    public function formatModuleName($unformatted)
    {
        return $unformatted;
    }

    public function getControllerDirectory()
    {
        return $this->_controllerDirs[$this->_defaultModule];
    }

    public function getDefaultAction()
    {
        return $this->_defaultAction;
    }

    public function getDefaultControllerName()
    {
        return $this->_defaultController;
    }

    public function getDefaultModule()
    {
        return $this->_defaultModule;
    }

    public function getParam(string $name)
    {
        return $this->_params[$name];
    }

    public function getParams()
    {
        return $this->_params;
    }

    public function getResponse()
    {
        return $this->_response;
    }

    public function isDispatchable(Zend_Controller_Request_Abstract $request)
    {
    }

    public function isValidModule($module)
    {
    }

    public function setControllerDirectory($path)
    {
        $this->_controllerDirs[$this->_defaultModule] = $path;
        return $this;
    }

    public function setParam($name, $value)
    {
        $this->_params[$name] = $value;
        return $this;
    }

    public function setParams(array $params)
    {
        $this->_params = $params;
        return $this;
    }

    public function setResponse(Zend_Controller_Response_Abstract $response = null)
    {
        $this->_response = $response;
        return $this;
    }
}